﻿using System;
using System.Data;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;
using Ysb.Components;
using System.Data.SqlClient;
public partial class Admin_PriceEdit : System.Web.UI.Page
{
    DataTable dt = null;
    PayModelService pod = new PayModelService();
    WayBillService ws = new WayBillService();
    public string ajax = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!AdminCheck.Check(this, 1))
        {
            Response.Redirect(AdminCheck.RedirectPage);
            return;
        }
        if (!Page.IsPostBack)
        {

            DataLoad();

        }
    }
    private void DataLoad()
    {


        dt = pod.GetCalType();



        List<TnoInfo> ls = new List<TnoInfo>();

        ls = new WayBillService().GetList(Request.QueryString["no"].ToString(), 4);

       
        if (ls.Count == 0)  
        {
            Tools.OpenWindow(this, "当前未选择允许编辑价单单据", Request.UrlReferrer.ToString());
            return;
        }
        string sql1 = "TotalWeight,DimensionsWeight, 'False' as Sep,TrackingNo, ChargedWt,FreightCharge,Memo1,Memo2,Memo3,Memo4,Duties,Premium,OtherCharge,Memo5,Total,CreateUserID";
        string sql2 = "Weight as TotalWeight,DimensionsWeight,'True' as Sep,SepNo as TrackingNo, ChargedWt, FreightCharge,Memo1,Memo2,Memo3,Memo4,Duties,Premium,OtherCharge,Memo5,Total,CreateUserID";
      
     using ( DataTable ndt = new WayBillService().GetBillMess(sql1, sql2, ls, 1))

        {
        SqlConnection conn = new SqlConnection("Initial Catalog=UnexDB2;Data Source=N-SERVER\\MSSQLSERVER2;User ID=sa;password=jckj2008;Max Pool Size = 1000;");
        conn.Open();
        conn.Close();
        SqlConnection.ClearAllPools();
        list.DataSource = ndt;
        list.DataBind();

        }

    // DataTable ndt = new WayBillService().GetBillMess(sql1, sql2, ls, 1);


     //   list.DataSource = ndt;
    //    list.DataBind();
   
      //  ndt.Dispose();


    }

    public DataTable GetType(object userid, object tno, object select)
    {
        if (userid.ToString().Trim() == "")
        {

            return dt;
        }
        else
        {
            if (select.ToString() != "0" && select.ToString() != "")
            {
        SqlConnection conn = new SqlConnection("Initial Catalog=UnexDB2;Data Source=N-SERVER\\MSSQLSERVER2;User ID=sa;password=jckj2008;Max Pool Size = 1000;");
        conn.Open();
        conn.Close();
        SqlConnection.ClearAllPools();
                ajax += " SetSelect('" + tno + "','" + ws.GetCalTypeName(select.ToString()).Trim() + "');";


            }
            return pod.GetUserCalType(userid.ToString());
        }









    }
    /// <summary>
    /// 获取货物名字
    /// </summary>
    /// <param name="no"></param>
    /// <returns></returns>
    public string GetName(string no)
    {
        return new WayBillService().GetName(no);
    }
    //获取费率
    public string GetPrice(object uid)
    {

        return new UserService().GetUserDgfbZF(uid.ToString());
    }
}
